18 #include "clock_config.h" 20 #include "fsl_debug_console.h" 25 #include "Driver_I2C.h" 30 #include "issdk_hal.h" 32 #include "gpio_driver.h" 38 #define FXLS896x_DATA_SIZE 6 58 const char *
pActivity[5] = {
"Unknown ",
"Rest ",
"Walking ",
"Jogging ",
"Running "};
66 .bits = {.config = 1},
88 .portPinConfig = {.pullSelect = kPORT_PullUp, .mux = kPORT_MuxAsGpio},
89 .interruptMode = kPORT_InterruptFallingEdge,
108 uint16_t lastReportedSteps;
123 PRINTF(
"\r\n ISSDK FXLS896x sensor driver example for Pedometer.\r\n");
130 if (ARM_DRIVER_OK != status)
132 PRINTF(
"\r\n I2C Initialization Failed\r\n");
137 status = I2Cdrv->PowerControl(ARM_POWER_FULL);
138 if (ARM_DRIVER_OK != status)
140 PRINTF(
"\r\n I2C Power Mode setting Failed\r\n");
145 status = I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
146 if (ARM_DRIVER_OK != status)
148 PRINTF(
"\r\n I2C Control Mode setting Failed\r\n");
155 if (ARM_DRIVER_OK != status)
157 PRINTF(
"\r\n Sensor Initialization Failed\r\n");
162 PRINTF(
"\r\n Successfully Initialized Gemini with WHO_AM_I = 0x%X\r\n", whoami);
166 PRINTF(
"\r\n Successfully Initialized Timandra with WHO_AM_I = 0x%X\r\n", whoami);
170 PRINTF(
"\r\n Successfully Initialized Newstein with WHO_AM_I = 0x%X\r\n", whoami);
174 PRINTF(
"\r\n Bad WHO_AM_I = 0x%X\r\n", whoami);
186 PRINTF(
"\r\n FXLS896x Sensor Configuration Failed, Err = %d\r\n", status);
189 PRINTF(
"\r\n Successfully Applied FXLS896x Sensor Configuration\r\n");
193 PRINTF(
"\r\n Pedometer successfully Initialized.");
194 PRINTF(
"\r\n\r\n Ready for measurements.");
215 if (ARM_DRIVER_OK != status)
217 PRINTF(
"\r\n ERROR : Read Data Failed!\r\n");
222 rawData.
accel[0] = ((int16_t)data[1] << 8) | data[0];
223 rawData.
accel[0] *= 16;
224 rawData.
accel[1] = ((int16_t)data[3] << 8) | data[2];
225 rawData.
accel[1] *= 16;
226 rawData.
accel[2] = ((int16_t)data[5] << 8) | data[4];
227 rawData.
accel[2] *= 16;
239 PRINTF(
"\r\n\r\n | Steps |\r\n");
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.
The fxls896x_drv.h file describes the FXLS8964/67AF driver interface and structures.
This defines the sensor specific information for I2C.
#define FXLS896x_SENS_CONFIG3_WAKE_ODR_50HZ
status_t SMC_SetPowerModeWait(void *arg)
Configures the system to WAIT power mode. API name used from Kinetis family to maintain compatibility...
#define BOARD_BootClockRUN
uint8_t data[FXLS8962_DATA_SIZE]
Access structure of the GPIO Driver.
#define PEDO_FILTER_TIME_DEFAULT
void pedometer_init(pedometer_t *pPedometer)
The interface function initialize the pedometer.
GENERIC_DRIVER_GPIO * pGpioDriver
int32_t FXLS896x_I2C_Initialize(fxls896x_i2c_sensorhandle_t *pSensorHandle, ARM_DRIVER_I2C *pBus, uint8_t index, uint16_t sAddress, uint8_t *whoami)
The interface function to initialize the sensor.
#define __END_WRITE_DATA__
#define PEDO_STEP_THRESHOLD_DEFAULT
This structure defines the Read command List.
#define I2C_S_SIGNAL_EVENT
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
#define FXLS8967_WHOAMI_VALUE
#define PEDO_FILTER_STEPS_DEFAULT
#define FXLS896x_SENS_CONFIG1_FSR_MASK
fxls896x_i2c_sensorhandle_t fxls896xDriver
void BOARD_InitDebugConsole(void)
#define FXLS896x_WHOAMI_VALUE
int32_t FXLS896x_I2C_Configure(fxls896x_i2c_sensorhandle_t *pSensorHandle, const registerwritelist_t *pRegWriteList)
The interface function to configure he sensor.
void pedometer_configure(pedometer_t *pPedometer, const pedometer_config_t *pConfig)
The interface function to configure the pedometer.
gpioConfigKSDK_t gpioConfigINT1
int32_t FXLS896x_I2C_ReadData(fxls896x_i2c_sensorhandle_t *pSensorHandle, const registerreadlist_t *pReadList, uint8_t *pBuffer)
The interface function to read the sensor data.
const registerwritelist_t cFxls896xConfigInitialize[]
FXLS896x Motion based Pedometer Register Write List.
#define I2C_S_DEVICE_INDEX
The pedometer.h file contains the interface and structure definitions for pedometer application...
This defines the configuration structure of the pedometer.
int main(void)
This is the The main function implementation.
void(* toggle_pin)(pinID_t aPinId)
#define PEDO_SPEED_PERIOD_DEFAULT
void(* pin_init)(pinID_t aPinId, gpio_direction_t dir, void *apPinConfig, gpio_isr_handler_t aIsrHandler, void *apUserData)
struct pedometer_t::pedometer_status_tag status
gpioHandleKSDK_t GREEN_LED
This defines the pedometer instance.
void FXLS896x_I2C_SetIdleTask(fxls896x_i2c_sensorhandle_t *pSensorHandle, registeridlefunction_t idleTask, void *userParam)
: The interface function to set the I2C Idle Task.
const registerreadlist_t cFxls896xOutput[]
Address of Data Output Registers.
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
debounce_count_t sleepcount_threshold
gpio_pin_config_t pinConfig
const registerreadlist_t cFxls896xDRDYEvent[]
Address of DATA Ready Status Register.
#define FXLS896x_DATA_SIZE
void(* set_pin)(pinID_t aPinId)
#define FXLS896x_I2C_ADDR
#define FXLS8974_WHOAMI_VALUE
#define __END_READ_DATA__
const char * pActivity[5]
Pedometer Mode Name Strings.
#define PEDO_FREQHZ_DEFAULT
The GPIO Configuration KSDK.
This structure defines the Write command List.
This defines the acceleration input data for the pedometer.
#define FXLS896x_INT_STATUS_SRC_DRDY_MASK
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
This structure defines the fxls896x raw data buffer.
#define FXLS896x_SENS_CONFIG3_WAKE_ODR_MASK
#define FXLS8964_WHOAMI_VALUE
fxos8700_accelmagdata_t rawData
int32_t pedometer_run(pedometer_t *pPedometer, ped_accel_t *pData)
The interface function excutes the pedometer algorithm.
#define FXLS896x_SENS_CONFIG1_FSR_2G